import App from './App'
import { HttpWidget } from '@/common/request/index.js'
import tools from '@/common/tools'
import api from '@/common/request/apis/index'
import i18n from '@/language'
Vue.use(new HttpWidget())

const msg = (title, duration=1500, mask=false, icon='none')=>{
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const prePage = ()=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}

Vue.prototype.$api = {msg, prePage};
Vue.prototype.$tools = tools
Vue.prototype.$imgUrl = 'http://www.dota2zizouqi.cn/'

if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
    Vue.prototype.$pc = false
} else {
    Vue.prototype.$pc = true
    let winWidth = document.documentElement.offsetWidth ||
    document.body.offsetWidth
    winWidth = winWidth < 1366 ? 1366 : winWidth
    let oHtml = document.getElementsByTagName('html')[0]
    oHtml.style.fontSize = 100 * winWidth / 1920 + 'px'
    window.addEventListener('resize', function () {
        let winWidth = document.documentElement.offsetWidth || document.body.offsetWidth
        winWidth = winWidth < 1366 ? 1366 : winWidth
        let oHtml = document.getElementsByTagName('html')[0]
        oHtml.style.fontSize = 100 * winWidth / 1920 + 'px'
    })
}
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
    ...App,
	i18n
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif